import  time
from mylib import UartCommend 
from mylib import Camera
# 初始化串口通信
uartcommend=UartCommend(uart_port=1, baudrate=115200)
# 初始化摄像头
camera = Camera()

while(True):
    img_roi, fps = camera.get_image()
    print("FPS:", fps)
    while(uartcommend.uart.any()):
        # 获取接收到的串口数据
        data = uartcommend.get_uart_data()
        if data:         
                if data[0] == 0x01:  # 如果数据是0x01，打开LED
                    camera.led.on()
                    uartcommend.send_uart_data(0x66)  # 发送确认消息 向左撞击                              
                elif data[0] == 0x02:  # 如果数据是0x02，关闭LED
                    camera.led.off()
                    uartcommend.send_uart_data(0x02)  # 发送确认消息 向右撞击
    